import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    finalUser: JSON.parse(window.localStorage.getItem('finalUserInfo')),
    addModalShow: false, // 添加学员的弹框显示
    username: null // 用户名
  },
  mutations: {
    // 登录
    changeUser (state, data) {
      state.finalUser = data
      // 设置本地存储
      window.localStorage.setItem('finalUserInfo', JSON.stringify(data))
    },
    // 退出登录
    outLogin () {
      window.localStorage.removeItem('finalUserInfo')
    },
    // 修改添加学员弹框展示状态
    changeShow (state, data) {
      state.addModalShow = data
    },
    // 改变 username
    changeUsername (state, data) {
      state.username = data
    }
  },
  actions: {
  },
  modules: {
  }
})
